#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
using namespace std;
int a[10][10] = { 0 };
int main() {
    int n, x, y, num = 0;
    scanf("%d", &n);
    a[x = 0][y = 0] = num = 1;
    while (num < n * n) {
        while (y < n-1 && !a[x][y + 1])
            a[x][++y] = ++num;
        while (x < n-1 && !a[x + 1][y])
            a[++x][y] = ++num;
        while (y > 0 && !a[x][y - 1])
            a[x][--y] = ++num;
        while (x > 0 && !a[x - 1][y])
            a[--x][y] = ++num;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            printf("%3d", a[i][j]);
        }
        printf("\n");
    }
    return 0;
}